package cn.demoncat.util.lang.entity.report;

import com.baomidou.mybatisplus.annotation.TableField;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * 统计
 * 
 * @author 延晓磊
 *
 * @since 2020年7月23日
 */
public class Count{

	// 计数
	@TableField(exist = false)
	protected long count = 0L;
	// 总额
	@TableField(exist = false)
	protected BigDecimal sum = BigDecimal.ZERO;

	public Count() {
		super();
	}

	public Count(long count, BigDecimal sum) {
		super();
		this.count = count;
		this.sum = sum;
	}

	public Count(long count) {
		super();
		this.count = count;
	}

	public Count(BigDecimal sum) {
		super();
		this.sum = sum;
	}

	/**
	 * 递增count
	 * 
	 * @return
	 * 
	 * @author 延晓磊
	 *
	 * @since 2020年7月22日
	 */
	public Count addCount() {
		return addCount(1);
	}

	/**
	 * 递增count
	 * 
	 * @param i
	 * @return
	 * 
	 * @author 延晓磊
	 *
	 * @since 2020年7月22日
	 */
	public Count addCount(long i) {
		count += i;
		return this;
	}

	/**
	 * 递增sum
	 * 
	 * @param i
	 * @return
	 * 
	 * @author 延晓磊
	 *
	 * @since 2020年7月22日
	 */
	public Count addSum(BigDecimal i) {
		sum = sum.add(i);
		return this;
	}

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	public BigDecimal getSum() {
		return sum;
	}

	public void setSum(BigDecimal sum) {
		this.sum = sum;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Count count1 = (Count) o;
		return count == count1.count &&
				Objects.equals(sum, count1.sum);
	}

	@Override
	public int hashCode() {
		return Objects.hash(count, sum);
	}

	@Override
	public String toString() {
		return "Count{" +
				"count=" + count +
				", sum=" + sum +
				'}';
	}
}
